import request from "../../utils/request";

//订单预览

const getOrderPreviewData = ()=>{
    return request.get('/api/orders/preview')
}
// 创建订单

const createOrder = (params)=>{
    return request({
        url:'/api/orders',
        method:'post',
        params
    })
}
// 获得订单支付二维码
const getPayCode = (order,payType)=>{
    return request.get(`/api/orders/${order}/pay`,{params:{type:payType}})
}

// 获取支付订单状态

const getPayStatus = (orderId)=>{
    return request({
        url:`/api/orders/${orderId}/status`,
        method:'get',
    })
}

const getOrderDetail = (orderId)=>{
    return request({
        url:`/api/orders/${orderId}`,
        method:'get',
        params:{include:'orderDetails.goods,address'}
    })
}

// 获取订单列表

const getOrderList = (status)=>{
    return request.get('/api/orders',{params:{include:'orderDetails.goods',status:status}})
}
export {
    getOrderPreviewData,
    createOrder,
    getPayCode,
    getPayStatus,
    getOrderDetail,
    getOrderList
}